package com.atguigu.juc1205.demo;

import java.util.HashMap;

/**
 * @Author Joey
 * @Date 2021/9/23 13:53
 * @Description
 * 1、函数式编程
 *      int age = 23;
 *      y = kx + 1;
 *
 *  拷贝小括号，写死右箭头，落地大括号
 *  @FunctionalInterface
 *  default
 *  static
 */
public class LambdaExpressDemo02 {

    public static void main(String[] args) throws Exception {

        System.out.println(Long.bitCount(10L));
//        Foo foo = () -> {
//            System.out.println("1");
//        };
//        foo.sayHello();

//        Foo foo = (int x,int y) -> { return x + y; };
//        Foo foo = (int x,int y) -> x + y;
        Foo foo = Integer::sum;
        System.out.println(foo.add(3, 2));
        System.out.println(foo.mul(3, 2));
        System.out.println(Foo.sub(3, 2));

        new HashMap<String,Object>(2){{
            put("1","1");
        }};
        new HashMap<String,Object>(2){{
            put("1","1");
        }};

        new Phone() {{
            sayHello();
        }};
    }

}

@FunctionalInterface
interface Foo{
//    public void sayHello();
    public int add(int x,int y);

    default int mul(int x,int y){
        return x * y;
    }

    static int sub(int x,int y){
        return x - y;
    }

}